<%@ Page Language="C#" MasterPageFile="~/MasterPages/Learning.Master" AutoEventWireup="true" CodeBehind="VirtualEarth.aspx.cs" Inherits="Mindscape.BackgroundMotion.Website.Learn.VirtualEarth" Title="Code: Learn about Virtual Earth" %>
<asp:Content ID="Content3" ContentPlaceHolderID="BodyContent" runat="server">

    <h2>What is Virtual Earth?</h2>
    <p>Virtual Earth is an online global mapping solution provided by Microsoft. Using AJAX you can quickly and easily browse around the world and explore maps and aerial photos of any part of the globe. Microsoft provide an API to integrate Virtual Earth into 3rd party web sites which is what we have done with BackgroundMotion.</p>
    <br />
    <div align="center">
        <a href="/Learn/PlayVideo.aspx?v=Nugget1" target="page" onClick="window.open('','page','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=450,height=350,titlebar=yes')"><img border="0" src="/Images/Dev/VideoNugget1.jpg" /></a><br />
        <p>Watch as John-Daniel explains about Virtual Earth</p>    
    </div>
    <br />    
    <h2>How we used Virtual Earth in BackgroundMotion</h2>
    <p>In BackgroundMotion we used Virtual Earth when adding a contribution and when viewing a contribution. On the add contribution page you can use Virtual Earth to set the location a video or picture was taken and on the view page you can get a map showing where the specific contribution was taken.</p>
    <h3>Display a map</h3>
    To integrate Virtual Earth we need to add some basic JavaScript to the page, the following is added into the &lt;head&gt; tag of the webpage:
    <pre>
    &lt;script type="text/javascript" src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=5"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
      var map = null;
      var pinid = 0;
            
      function GetMap()
      {
         map = new VEMap('myMap');
         map.LoadMap();
         map.SetZoomLevel(10);
      }
    &lt;script&gt;
    </pre>
    
    <p>Once you have done that we need to create a div tag to host the Virtual Earth view. Note that the ID of this div matches the value passed into the VEMap() constructor.</p>
    
    <pre>&lt;div id='myMap' style="position:relative; width:300px; height:300px;"&gt;&lt;/div&lt;</pre>
   
    <p>Now all that is left is to wire up the JavaScript so that it knows to load the div element to host the VirtualEarth view port. We do this by adding an onload hook on the body tag:</p>
    
    <pre>&lt;body onload="GetMap();"&gt;</pre>
    
    <h2>Where can I find out more information?</h2>
    
    <ul>
      <li><a href="http://dev.live.com/virtualearth/">The Virtual Earth developer site</a></li>
      <li><a href="http://dev.live.com/virtualearth/sdk/">The interactive Virtual Earth SDK</a></li>
      <li><a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=537&SiteID=1">The official Virtual Earth forums</a></li>
      <li><a href="http://www.viavirtualearth.com/">The Via Virtual Earth community website</a></li>
      <li><a href="http://blogs.msdn.com/virtualearth/">The Virtual Earth developer blog</a></li>
    </ul>
    
</asp:Content>
